﻿using RBAC_Class.Infrastructrue.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBAC_Class.Infrastructrue.Implement
{
    public class BaseRepository<T>: IBaseRepository<T> where T : class
    {
        private readonly DataDbContext db;
        public DataDbContext Context
        {
            get
            {
                return db;
            }
        }
        public BaseRepository(DataDbContext db)
        {
            this.db = db;
            this.db = db;
        }

        public int Add(T entity)
        {
            db.Set<T>().Add(entity);
            return db.SaveChanges();
        }

        public IQueryable<T> GetAll()
        {
            return db.Set<T>().AsQueryable();
        }

        public int Update(T entity)
        {
            db.Set<T>().Update(entity);
            return db.SaveChanges();
        }
    }
}
